package com.apes.scm.masterdata.finance.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.masterdata.finance.model.PaymentMethodType;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * 收款方式接口
 *
 * @author wuq
 * @create 2018-03-22 15:00
 */
public interface PaymentMethodRepository extends CustomRepository<PaymentMethodType, String> {

    @Query("SELECT t FROM PaymentMethodType t where t.valid = true and t.id in ('01','08','02') ")
    Page<PaymentMethodType> findAllForUse(Pageable pageable);

    @Query("SELECT t FROM PaymentMethodType t where t.valid = true and t.paymentMethodClass = 'both' or t.paymentMethodClass = 'supplier'")
    Page<PaymentMethodType> findAllForPurchasePayment(Pageable pageable);

    @Query("SELECT t FROM PaymentMethodType t where t.valid = true and t.paymentType = 'actualCollection' and (t.paymentMethodClass = 'both' or t.paymentMethodClass = 'customer')")
    Page<PaymentMethodType> findAllForPay(Pageable pageable);


    @Query("SELECT t FROM PaymentMethodType t where t.valid = true")
    Page<PaymentMethodType> findAllPay(Pageable pageable);

    //01现金  02银行卡  03转账  08微信门店
    @Query("SELECT t FROM PaymentMethodType t where t.valid = true and t.id in ('01','02','03','08')")
    Page<PaymentMethodType> findSomePay(Pageable pageable);

    @Query("SELECT t FROM PaymentMethodType t where t.retailValid = true and ((t.name like %:value%) or (t.id like %:value%))")
    Page<PaymentMethodType> findAllPayByRetailValidIsTrue(@Param("value") String value, Pageable pageable);



}
